<?php
declare(strict_types=1);
/**
 * Created by project.
 * User: huanzipap
 * Date: 2023/5/11
 * Time: 15:01
 */

namespace App\Model;

use Hyperf\Database\Model\Model;
use Hyperf\Database\Model\SoftDeletes;

class Notify extends Model
{
    use SoftDeletes;

    protected ?string $table='notify';
    public bool $timestamps = true;

    protected array $fillable = ['party_id','module','relation_id','uid','file_list'];


    public function news(): \Hyperf\Database\Model\Relations\belongsTo
    {
        return $this->belongsTo(News::class, 'relation_id', 'id');
    }


    public function task(): \Hyperf\Database\Model\Relations\belongsTo
    {
        return $this->belongsTo(Task::class, 'relation_id', 'id');
    }

    public function act(): \Hyperf\Database\Model\Relations\belongsTo
    {
        return $this->belongsTo(Act::class, 'relation_id', 'id');
    }


    public function setFileListAttribute($value)
    {
        $this->attributes['file_list'] = json_encode( $value);
    }

    public function getFileListAttribute($value)
    {
        return $value != null ? json_decode($value,true) : $value;
    }

}